<!--  -->
<template>
  <div class="container">
    <navbar
      class="de-navbar"
      :vaniconL="true"
      :noRight="true"
      :noLeft="false"
      :vaniconR="true"
      iconNameL="arrow-left"
      iconNameR="setting-o"
      @clickLeft="goBack"
      bgcolor="rgb(55, 81, 255) !important"
      bgImage="linear-gradient(rgb(55, 81, 255) 0%, rgb(76, 99, 255) 50%, rgb(91 112 255) 75%, rgb(107 127 255) 100%) !important"
      >AI题库</navbar
    >
    <div style="height: 0.45rem"></div>
    <div class="content">
      <van-cell-group>
        <van-cell
          v-for="(item, index) in classList"
          :key="index"
          :title="item.title"
          @click="toTestDetail(item)"
          is-link
          :label="`${item.radio} / ${item.sum}`"
        />
      </van-cell-group>
    </div>
  </div>
</template>

<script>
import navbar from "@/components/navbar";
import { Toast, Dialog } from "vant";
import { mapGetters } from "vuex";
import { getSubjects } from "@/api/doctor";
export default {
  name: "aiTest",
  data() {
    return {
      classList: [],
    };
  },

  components: { navbar },

  computed: { ...mapGetters(["userData"]) },

  created() {
    this.getList();
  },
  mounted() {},

  methods: {
    // 返回上一页
    goBack() {
      this.$router.replace({ path: "/Training" });
    },
    //题目详情
    toTestDetail(item) {
      this.$router.push({
        name: "testDetail",
        params: {
          subjectsId: item.subjectsId,
          title: item.title,
        },
      });
    },
    // 列表
    getList() {
      const toast = Toast.loading({
        duration: 0, // 持续展示 toast
        forbidClick: true,
        overlay: true,
        message: "加载中",
      });
      let data = {
        userId: JSON.parse(this.userData).id,
      };
      getSubjects(data).then((res) => {
        if (res.data.status == 200) {
          this.classList = res.data.info;
          Toast.clear();
        } else {
          Toast.fail(res.data.msg);
        }
      });
    },
  },
};
</script>
<style lang='scss' scoped>
@import "../../assets/css/utils";
.container {
  position: relative;
  height: 100%;
  background: #f5f5f5;
  padding-bottom: 0.2rem;
  & .content {
    width: 95%;
    margin: auto;
    margin-top: 0.1rem;
  }
}
.van-cell__title {
  text-align: left;
}
</style>